<template>
  <view>
    <!-- 标题区域 -->
    <view class="header_txt">
      <view class="back"
            @click="goback">
        <image src="/static/img/back3.png"></image>
      </view>
      <view class="title"> 我要提问 </view>
    </view>
    <view class="choosecategory">
      <view class='titlechoose'>请选择类型</view>
      <view class='itemcategorybox'>
        <block>
          <view v-for="el in cateList"
                :key="el.id"
                @click="cateChoose(el)"
                class='itemcategory '>{{el.name}}</view>

        </block>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      cateList: []
    }
  },
  onLoad() {
    this.getCateLst()
  },
  methods: {
    cateChoose(e) {
      let obj = JSON.stringify(e)
      uni.navigateTo({
        url: `/pages/askquestion/myask?obj=${obj}`
      })
    },
    async getCateLst() {
      let { data } = await this.$http.post('/ask/cate')
      this.cateList = data.data
    }
  }
}
</script>

<style lang="scss">
/* 头部区域 */
.header_txt {
  width: 750rpx;
  overflow: hidden;
  height: 88rpx;
  background-color: #fff;

  .back {
    position: absolute;
    top: 14rpx;
    left: 14rpx;
    width: 60rpx;
    height: 60rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    image {
      width: 48rpx;
      height: 48rpx;
    }
  }

  .right {
    position: absolute;
    top: 14rpx;
    right: 14rpx;
    width: 60rpx;
    height: 60rpx;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .title {
    text-align: center;
    height: 88rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    font-weight: bold;
  }
}
/* 类型选择 */
.choosecategory {
  width: 100%;
  height: 100%;
  position: relative;
  /* padding: 0 30rpx; */
  padding: 0 7rpx;
  background-color: #ffffff;
}
.titlechoose {
  height: 100rpx;
  font-size: 28rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: #666666;
  padding-top: 40rpx;
  padding-left: 17rpx;
  line-height: 60rpx;
  width: 100%;
}
.closeimg {
  height: 21rpx;
  width: 21rpx;
  position: absolute;
  top: 30rpx;
  right: 30rpx;
}
.itemcategorybox {
  height: auto;
  width: 100%;
  display: flex;
  /* justify-content: space-between; */
  justify-content: flex-start;
  flex-wrap: wrap;
}
.itemcategory {
  width: 164rpx;
  height: 70rpx;
  margin: 0 10rpx;
  text-align: center;
  line-height: 70rpx;
  border: 1rpx solid #f5f5f5;
  background: #f5f5f5;
  border-radius: 6rpx;
  margin-bottom: 20rpx;
}
.activecolor {
  border: 1rpx solid #fcb630;
  background: #ffedca;
}
</style>
